const defaultState = {
  searchText: 'hot',
  inputHistory: ['safarishi', '001']
}

export default function(state = defaultState, action) {
  switch (action.type) {
    case 'CLEAR_SEARCH_TEXT':
      return {
        ...state,
        searchText: ''
      }
    case 'UPDATE_SEARCH_TEXT':
      return {
        ...state,
        searchText: action.payload.text
      }
    case 'FILL_SEARCH_INPUT_WITH_TAKED_HISTORY':
      return {
        ...state,
        searchText: action.payload.value
      }
    case 'UPDATE_INPUT_HISTORY':
      return {
        ...state,
        inputHistory: action.payload.inputHistory
      }
    default:
      return state
  }
}